Visibility specifiers for functions are as follows:
i. The public visibility specifier for functions makes them visible
externally and internally and creates a getter function for storage/ state
variables.
ii. The private visibility specifier for functions makes them visible only
in the current contract.
iii. The external visibility specifier for functions makes them visible only
externally, i.e., it can only be message-called via this.func.
iv. The internal visibility specifier for functions makes them visible only
internally; functions can be pure, view, or payable. Because view
functions do not cost any gas, it is very much recommended to use a
view if a function does not write any data on the blockchain.
Modifiers for function: There exist modifiers for state variables, events, and
event arguments:
i. For functions, the pure modifier disallows modification or access of
state.
ii. For functions, the view modifier disallows modification of state.
iii. For functions, the payable modifier allows the receipt of Ether
together with a call; the reserved word returns need to be specified and
then in regular brackets to specify, which type does function returns if
the function returns some value. Here, it will be a string. There is no
need for the returns statement if the function does not return any
value.
State variable: To access a state variable, you do not need the prefix this,
as is common in other languages. A common practice is to write function
arguments with underscore syntax (_ message) because of that, the
convention coming from J avaScript where private methods and variables
start with an underscore_ , your code will work fine with and without
underscores, but it is cleaner with them.
Memory: It will work fine if you write your code without memory and set
pragma to some version under 0.5 .* but when you change your compiler to
above 0.5 .* a compile error will be generated by EVM. This happens
because the EVM has three areas where it can store items: The first area is